<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{margin: 0;padding: 0;list-style-type: none;}
        input{
            width: 200px;
            height: 50px;
            background-color: #ccc;
            border: 2px solid black;
            font-size: 20px;
            margin-left: 200px;
            margin-top: 30px;
        }
    </style>
</head>
<body>
    <input type="text" id="username">
    <script>
        let inputUserName = document.querySelector('#username')
        //任意键按下触发
        // inputUserName.onkeydown = function(){
        //     console.log("按下触发");
        // }
        //任意键抬起时触发
        inputUserName.onkeyup = function(){
            console.log("抬起触发");
        }
        //输出键按下时触发
        inputUserName.onkeypress = function(){
            console.log("输出键按下触发");
        }
        /*
            键盘事件：

        */
    </script>
</body>
</html>